<?php

class SController extends CController {

    /**
     * @var string the default layout for the controller view. Defaults to 'column1',
     * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
     */
    public $layout = 'main';

    /**
     * @var array context menu items. This property will be assigned to {@link CMenu::items}.
     */
    public $menu = array();

    /**
     * @var array the breadcrumbs of the current page. The value of this property will
     * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
     * for more details on how to specify this property.
     */
    public $breadcrumbs = array();
    public $assetsUrl;
    public $imagesPath;
    public $cssPath;
    public $jsPath;
    public $pageHeader;
    
    /**
     * @var string site language
     */
    public $language='en';
    
    /*
     * @var captcha mode
     */
    public $captchaMode; // value: default, math, mathverbal, logical, words
    
    /**
     * @var string Current country code
     */
    public $countryCode;
    public $debugMode = false;
    public $formId = 'form-Id';

    public function init() {
        parent::init();
        
        //$this->assetsUrl = '../assets';
        
        $theme=Yii::app()->theme->baseUrl;
        $this->imagesPath = $theme . '/images';
        $this->cssPath = $theme . '/css';
        $this->jsPath = $theme . '/js';

        $this->debugMode = Yii::app()->params['debugMode'];
        $this->language=Yii::app()->language;
        //$this->captchaMode = isset(Yii::app()->params['captchaMode'])? Yii::app()->params['captchaMode']:null;
        //$this->countryCode = Environment::isProduction()? Yii::app()->geoip->lookupCountryCode():Yii::app()->params['defaultCountryCode'];

    }
    
    protected function performAjaxValidation($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === $this->formId) {
            echo CActiveForm::validate($model);
            Yii::app()->end();
        }
    }//end function

    public function setFlash($type, $message) {
        Yii::app()->user->setFlash($type, $message);
    }//end function
    
}